/**
 * Project Name:springBoot-controller
 * File Name:ThymeleafController.java
 * Package Name:com.libra.controller
 * Date:2018年11月12日下午4:02:59
 * Copyright (c) 2018, wangzhch All Rights Reserved.
 *
*/

package com.libra.controller;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.libra.model.User;
import com.libra.service.ThymeleafService;

/**
 * ClassName:ThymeleafController <br/>
 * Date:     2018年11月12日 下午4:02:59 <br/>
 * @author   wangzhch
 * @version  
 * @since    JDK 1.8
 * @see 	 
 */
@Controller
@RequestMapping("thymeleaf")
public class ThymeleafController {
	private Logger log = LoggerFactory.getLogger(ThymeleafController.class);
	@Autowired
	private ThymeleafService thymeleafService;
	
	@RequestMapping("/hello")
	public String hello(Map<String,String> map) {
		map.put("name", "张三2");
		return "hello";
	}
	/**
	 * 
	 * login:(这里用一句话描述这个方法的作用). <br/>
	 * @author wangzhch
	 * @param user
	 * @param model
	 * @return
	 * @since JDK 1.8
	 * @ModelAttribute(value = "users")  这里的users涉及到页面显示的值
	 */
	@RequestMapping("/login")
	public String login(@ModelAttribute(value = "users") User user,Model model) {
//	public String login(@RequestBody User user,Model model) {
		log.info("login:{}",JSON.toJSONString(user));
//		model.addAttribute("user", user);
		return "user";
	}
}

